// Order.java
class Order {
    private static int nextId = 1; // 静态变量，用于生成唯一ID
    
    private int orderId; 
    private Customer customer;
    private Coffee coffee;
    private int quantity;
    private String status;
    
    public Order(Customer customer, Coffee coffee, int quantity) {
        this.orderId = nextId++;
        this.customer = customer;
        this.coffee = coffee;
        this.quantity = quantity;
        this.status = "已下单";
    }
    
    // 处理订单的方法
    public boolean processOrder(Payment selectedPayment) {
        double total = coffee.getPrice() * quantity;
        
        if (customer.makePayment(total)) {
            this.status = "已完成";
            System.out.println("订单#" + orderId + " 处理成功!");
            
            // 顾客饮用咖啡
            for (int i = 0; i < quantity; i++) {
                customer.drinkCoffee(coffee);
            }
            
            return true;
        } else {
            this.status = "支付失败";
            return false;
        }
    }
    
    // 显示订单详情
    public void displayOrder() {
        System.out.println("订单号: #" + orderId);
        System.out.println("顾客: " + customer.getName());
        System.out.println("咖啡: " + coffee.getName() + " × " + quantity);
        System.out.println("总价: ¥" + (coffee.getPrice() * quantity));
        System.out.println("状态: " + status);
    }

    public Coffee getCustomer() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'getCustomer'");
    }

    public static Order fromFileString(String line) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'fromFileString'");
    }
}
